package com.example;

import com.example.config.AppConfig;
import com.example.config.DruidConfig;
import com.example.entity.User;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import javax.sql.DataSource;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {AppConfig.class, DruidConfig.class})
public class ApplicationContextTest {

    @Autowired
    private User user;

    @Autowired
    private DataSource dataSource;

    @Test
    public void testUserInjection() {
        Assert.assertNotNull("User bean is null", user);
        System.out.println("Injected User: " + user);
    }

    @Test
    public void testDataSource() {
        Assert.assertNotNull("DataSource is null", dataSource);
        System.out.println("Configured DataSource: " + dataSource);
    }
}
